import { ContainerService } from "shared/component/container/ContainerService";
import EventBinder from "shared/component/event/EventBinder";
import Log4R from "shared/component/log/Log4R";
const loginfo = Log4R.getLog('info');
export class ObjectServiceImpl extends ContainerService<Ctn.ObjectService, Ctn.ObjectEntity> implements Ctn.ObjectService {
    protected serverCalls: (keyof this)[] = [];
    protected serviceName: keyof Ctn.Services = "objectService";
    /** 实例监听器 */
    protected creatObjEventBinder = new EventBinder<(p: Instance) => void>()
    /** 实例添加时监听 */
    onObjCreate = this.creatObjEventBinder.bind();
    public run(): void {
        this.startObjEvent()
    }
    startObjEvent() {
        game.Workspace.GetDescendants().forEach(c => {
            this.creatObjEventBinder.callBack(c)
        })
        game.Workspace.DescendantAdded.Connect(c => {
            this.creatObjEventBinder.callBack(c)
        })
    }
}